import { FormProps, FormSchema } from '@/components/Table'
import { BasicColumn } from '@/components/Table/src/types/table'
import api from '@/api'
const { channelUserList } = api
// 渠道列表
export function getChannelBasicColumns(): BasicColumn[] {
  return [
    {
      title: '渠道编码',
      align: 'left',
      dataIndex: 'channelCode'
    },
    {
      title: '渠道名称',
      customEllipsis: true,
      align: 'left',
      dataIndex: 'channelName'
    },
    {
      title: '自定义',
      width: 80,
      dataIndex: 'switchFlag'
    },
    {
      title: '创建人',
      width: 160,
      dataIndex: 'createBy'
    },
    {
      title: '创建时间',
      align: 'left',
      width: 160,
      dataIndex: 'createTime'
    },
    {
      title: '操作',
      width: 96,
      dataIndex: 'operate'
    }
  ]
}
// 搜索列表
let regUserList: any[] = []
export function getSearchFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 80,
    baseColProps: {
      span: 6,
      md: 10,
      xl: 8,
      xxl: 6
    },
    schemas: [
      {
        field: 'channelCode',
        label: '渠道编码',
        component: 'Input'
      },
      {
        field: 'channelName',
        label: '渠道名称',
        component: 'Input'
      },
      {
        field: 'createBy',
        label: '创建人',
        component: 'ApiSelect',
        componentProps: {
          api: channelUserList,
          resultField: 'result',
          labelField: 'userName',
          valueField: 'userId',
          showSearch: true,
          immediate: true,
          optionFilterProp: 'label'
        }
      }
    ]
  }
}
function searchUser(input: any, option: any) {
  return option.userName && option.userName.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
// 渠道信息表单
export function getChannelFormConfig(): Partial<FormProps> {
  return {
    layout: 'vertical',
    showActionButtonGroup: false,

    baseColProps: {
      span: 24,
      style: {
        marginBottom: '4px'
      }
    },
    schemas: [
      {
        field: 'customStatus',
        component: 'Switch',
        label: '自定义开关',
        defaultValue: 1,
        required: true,
        componentProps: {
          checkedChildren: '启用',
          unCheckedChildren: '停用',
          checkedValue: 1,
          unCheckedValue: 0
        }
      },
      {
        field: 'logo1',
        component: 'Input',
        label: '数票通logo',
        required: false
      },
      {
        field: 'logo2',
        component: 'Input',
        label: '财税BPailogo',
        required: false
      },
      {
        field: 'serviceLink',
        component: 'Input',
        label: '联系客服链接',
        required: false
      },
      {
        field: 'servicePhone',
        component: 'Input',
        required: false,
        label: '联系客服电话'
      },
      {
        field: 'sellerSlogan',
        component: 'Input',
        required: false,
        label: '商家宣传语',
        componentProps: {
          maxLength: 10
        }
      },
      {
        field: 'sellerInfo',
        component: 'Input',
        required: false,
        label: '商家联系信息',
        componentProps: {
          maxLength: 10
        }
      }
    ]
  }
}
